<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改密码</title>
<link rel="stylesheet" href="<%=basePath %>/bootstrap/css/bootstrap.min.css">

    <script src="<%=basePath %>/js/jquery.min.js"></script>
	<script src="<%=basePath %>/bootstrap/js/bootstrap.min.js"></script>


	<link rel="stylesheet" href="<%=basePath%>/css/toastr.min.css">
	<script src="<%=basePath%>/js/toastr.min.js"></script>
	<script src="<%=basePath%>/js/toastrinit.js"></script>


	
<script type="text/javascript">
$(document).ready(function(){
	 $("#btn_save").click(function(){
		var password1 = $("#password1").val();
		var password2 = $("#password2").val();
		if(password1 == "" || password2 ==""){
			toastr.error(" <spring:message code='user.change.password.empty'/>");
			return ;
		}
		if(password1 != password2){
			toastr.error(" <spring:message code='user.change.password.inconsistency'/>");
			return ;
		}

		$.ajax({
            type: "POST",
            url: "<%=basePath %>/user/changePassword.do",
            data: {userId:"${userId}",password : password1 },	
            success: function(data){
           	    toastr.success("<spring:message code='base.success'/>");
               
            } ,error:function(data){
       			 toastr.error("<spring:message code='base.error'/>");
       	    }
        });
     }); 

	
});//document结束


</script>

</head>
<body >
<br/>
<div class="container">

<form class="form-horizontal">
  <div class="form-group" style="text-align:center">
    <label for="password1" class="col-sm-4 col-xs-4 control-label"> <spring:message code='user.change.password'/> </label>
    <div class="col-sm-4 col-xs-4">
      <input type="password" class="form-control" id="password1" >
    </div>
  </div>
  <div class="form-group" style="text-align:center">
    <label for="password2" class="col-sm-4 col-xs-4 control-label"> <spring:message code='user.change.password.confirmation'/></label>
    <div class="col-sm-4 col-xs-4">
      <input type="password" class="form-control" id="password2">
    </div>
  </div>
 
</form>

  <div  class="col-sm-offset-5 col-xs-offset-5">   
	  <button id="btn_save" 	type="button" class="btn btn-primary"><spring:message code='base.save' /></button>
	</div>
		
</div>

</body>
</html>